package com.polaris.live.adapter.level

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.polaris.live.R
import com.polaris.live.resp.back_resp.UserPartyGameMedal
import com.polaris.live.utils.image.ImageUtils
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder

/**
 * GameLevelBannerAdapter
 *
 * @author Created by 半仙 on 2024/4/19/019 14:54
 */
class GameLevelBannerAdapter : BaseBannerAdapter<UserPartyGameMedal>() {
    override fun bindData(
        holder: BaseViewHolder<UserPartyGameMedal>?,
        data: UserPartyGameMedal?,
        position: Int,
        pageSize: Int,
    ) {
        val image = holder?.findViewById<ImageView>(R.id.game_level_banner_item) ?: return
        if (data?.createTime == null) {
            Glide.with(image.context).load(ImageUtils.imgPath(data?.fallbackPhotoUrl)).into(image)
        } else {
            Glide.with(image.context).load(ImageUtils.imgPath(data.photoUrl)).into(image)
        }
    }

    override fun getLayoutId(viewType: Int) = R.layout.adapter_game_level_banner
}